import 'dart:ui';

import 'package:flustars/flustars.dart';
import 'package:flutter/material.dart';
import 'package:yuan_hang_app/res/w_constant.dart';

class SizeUtils {
  SizeUtils._();

  static double screenW() {
    return MediaQuery.of(WConstant.appContext!).size.width;
  }

  static double screenH() {
    return MediaQuery.of(WConstant.appContext!).size.height;
  }

  static double screenWidthPX() {
    return window.physicalSize.width;
  }

  static double screenHeightPX() {
    return window.physicalSize.height;
  }

  static double statusBar() {
    //  return window.padding.top / window.devicePixelRatio;
    return MediaQuery.of(WConstant.appContext!).padding.top;
  }

  static double bottomBar() {
    // return window.padding.bottom / window.devicePixelRatio;
    return MediaQuery.of(WConstant.appContext!).padding.bottom;
  }
  static double devicePixelRatio() {
    // return window.padding.bottom / window.devicePixelRatio;
    return MediaQuery.of(WConstant.appContext!).devicePixelRatio;
  }
}

extension doubleFit on double {
  double get px {
    return this * window.physicalSize.width / window.devicePixelRatio / 375.0;
  }
}

extension intFit on int {
  double get px {
    return this * window.physicalSize.width / window.devicePixelRatio / 375.0;
  }
}
